const Router = require('koa-router')
//中间件
const { auth } = require('../middleware/auth_middleware')
const { friendIdVaild, preventFriend, preventagree, paramsVaild } = require('../middleware/friend_middleware')
//控制器
const { beFriend, agreeFriend, ignoreFriend, breakFriend, followMyFriend, myFollowFriend, myFriend } = require('../controller/friendship_controller')
const { Chatrefer } = require('../controller/Chat_controller')
const router = new Router({ prefix: '/friend' })

//使状态为0  中间件先查询是否为好友
router.post('/into', auth, friendIdVaild, preventFriend, beFriend)

//回关
router.post('/be', auth, friendIdVaild, preventagree, agreeFriend)

//取消关注好友(相互关系)
router.post('/hate', auth, friendIdVaild, ignoreFriend)

//取消关注好友
router.post('/break', auth, friendIdVaild, breakFriend)

//查询关注我的好友
router.get('/fan', auth, paramsVaild, followMyFriend)

//查询我关注的好友
router.get('/follow', auth, paramsVaild, myFollowFriend)
//查询我的好友
router.get('/friend', auth, paramsVaild, myFriend)

//查询聊天记录
router.get('/chat', auth, paramsVaild, Chatrefer)
module.exports = router